package cn.zhl.optional;

import java.util.Optional;

/**
 * @program: demos
 * @description:
 * @author: 刘振华
 * @create: 2020-04-21 16:56
 **/
public class OptionalTest {
	public static void main(String[] args) {
//        Optional<String> op = Optional.of("hello");
		Optional<String> op = Optional.empty();
//        Optional<String> op = Optional.ofNullable(null);
		op.ifPresent(s -> System.out.println(s));
//        System.out.println(op.orElse("orElse"));
//        System.out.println(op.orElseGet(()->"abc"));
//        op.ifPresent(System.out::println);
		System.out.println(op.map(s -> s + 1).orElse("myOrElse"));
	}
}
